﻿<%@ Page Language="C#" Inherits="TA.Turbo.TPage" %>

<%@ Import Namespace="System.Linq" %>
<%@ Import Namespace="TA.DotNetUtils" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
	static string[] _excluded = new[] {
		".svn",
		"bin",
		"App_Code",
		"Empty",
		"Test",
		"Res",
	};
	protected override void OnLoad(EventArgs e)
	{
		base.OnLoad(e);

		this.rpt.Value.Entries = new ReflectionRepeaterEntries();
		this.rpt.Value.Entries.AddRange(
			System.IO.Directory.GetDirectories(
				System.IO.Path.GetDirectoryName(
					MapPath(Request.Path)))
			.Select(s => System.IO.Path.GetFileName(s))
			.Where(s =>
				!_excluded.Any(exc =>
					string.Equals(exc, s, StringComparison.CurrentCultureIgnoreCase))));
	}
	protected void rpt_BindItem(object s, TA.Turbo.BindEventArgs e)
	{
		Link l = e.Container.FindControl("link") as Link;
		string f = (string)e.DataEntry;
		l.Text = f;
		l.Href = f + "/";
	}
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
	<title>Turbo samples</title>
</head>
<body>
	<form id="form1" runat="server">
	<div>
		Please choose one of the following samples:
	</div>
	<t:Repeater runat="server" ID="rpt">
		<BindItem OnServer="rpt_BindItem" />
		<Header>
			<Template>
				<ul itemscontainer="1">
			</Template>
		</Header>
		<ViewItem>
			<Template>
				<li>
					<t:Link runat="server" ID="link">
					</t:Link>
				</li>
			</Template>
		</ViewItem>
		<Footer>
			<Template>
				</ul>
			</Template>
		</Footer>
	</t:Repeater>
	</form>
</body>
</html>
